﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Diagnostics;
using System.ComponentModel;
using WPFExcelReport.Helpers;
using System.Windows.Input;
namespace WPFExcelReport
{
    public partial class TB31
    {
        public TB31()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VBSGROE();
            this.DataContext = MV;
            InitializeComponent();
        }
        
        public override void LOADBYAUF()
        {
            TBMain.Clear();
            if (ORDERNUM.Length < 26)
                return;
            dwData = TBMain.NewRow();
            dwData["BSGMANDANT"] = app.Mandant;
            dwData["BSGART"] = ORDERNUM.Substring(0, 20);
            dwData["BSGKETTART"] = ORDERNUM.Substring(20, 6);
            SResult = TMV.QBSGROE05(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            vwMaster.View.MoveCurrentTo(-1);
        }

        public override void OnSave()
        {
            if (!IsSaved)
                return;
            if (dwMaster == null)
                return;
            TMV.UpdateBSGROE(dwMaster, app.company, 0);
            string key = KEY;
            KEY = "";
            KEY = key;
            base.OnSave();
        }

    }
}
